﻿// HSS.Logging.LogEventType.cs
// ----------------------------------------------------------------------------
// Licensed under the MIT license
// http://www.opensource.org/licenses/mit-license.html
// ----------------------------------------------------------------------------
// HighSpeed-Solutions, LLC
// Copyright (c) 2001-2010
// ----------------------------------------------------------------------------
// File:       LogEventType.cs
// Author:     HSS\gbanta
// Created:    08/12/2010
// Modified:   12/04/2010
// ----------------------------------------------------------------------------
namespace HSS.Logging
{
	#region Using Directives
	using System.Data;
	using System.Runtime.Serialization;
	using HSS.Data;
	#endregion

	#region LogEventType
	/// <summary>
	/// LogEventType represents an EventType from the HSS Log System.
	/// </summary>
	[DataContract]
	public class LogEventType : IDataContainer, IDataEntity
	{
		#region Constructors
		/// <summary>
		/// Constructor
		/// </summary>
		public LogEventType()
		{

		}
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="dr">The <see cref="IDataRecord"/> to construct this instance from.</param>
		public LogEventType(IDataRecord dr)
		{
			this.Load(dr);
		}
		#endregion

		#region IDataContainer Members
		/// <summary>
		/// The UniqueId for this record.
		/// </summary>
		public string Id
		{
			get { return this.EventTypeId.ToString(); }
			set { }
		}
		/// <summary>
		/// The Name for this record.
		/// </summary>
		public string Name
		{
			get { return this.EventType; }
			set { }
		}
		/// <summary>
		/// Gets this instance as an object.
		/// </summary>
		public object Data
		{
			get { return this; }
			set { }
		}
		#endregion

		#region ObjectModel
		/// <summary>
		/// Gets or sets the EventType Id.
		/// </summary>
		[DataMember]
		public int EventTypeId
		{
			get;
			set;
		}
		/// <summary>
		/// Gets or sets the EventType Name.
		/// </summary>
		[DataMember]
		public string EventType
		{
			get;
			set;
		}
		/// <summary>
		/// Gets or sets the EventType Description.
		/// </summary>
		[DataMember]
		public string Description
		{
			get;
			set;
		}
		#endregion

		#region IDataEntity Members
		/// <summary>
		/// Loads this instance from the provided <see cref="IDataRecord"/>.
		/// </summary>
		/// <param name="dr"></param>
		public void Load(IDataRecord dr)
		{
			this.EventTypeId = dr.GetInt32(dr.GetOrdinal("EventTypeId"));
			this.EventType = dr.GetString(dr.GetOrdinal("EventType"));
			this.Description = dr.GetString(dr.GetOrdinal("Description"));
		}
		#endregion
	}
	#endregion
}